package cn.com.css.taxInspection.gt3.service.impl;


import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import javax.annotation.Resource;

import cn.com.css.taxInspection.common.constants.Constants;
import cn.com.css.taxInspection.gt3.entity.*;
import cn.com.css.taxInspection.gt3.service.*;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import cn.com.css.taxInspection.gt3.mapper.JcAyxxMapper;
import cn.com.css.taxInspection.system.service.impl.HttpSessionService;
import cn.com.css.taxInspection.util.TsBqUtils;
import cn.com.css.taxInspection.workflow.entity.WorkflowInspectionHearEntity;
import cn.com.css.taxInspection.workflow.service.WorkflowInspectionHearService;

@Service
public class JcAyxxServiceImpl extends ServiceImpl<JcAyxxMapper, JcAyxxEntity> implements JcAyxxService {
    @Resource
    private HttpSessionService httpSessionService;
    @Resource
    private WorkflowInspectionHearService workflowInspectionHearService;
    @Resource
    private JcAjxxService jcAjxxService;
    @Resource
    private JcAyxxDebugService jcAyxxDebugService;
    @Resource
    private JcAyxxDebugJgryService jcAyxxDebugJgryService;
    @Resource
    private DmJcAjztService dmJcAjztService;
    @Resource
    private DmGySwjgService dmGySwjgService;
    @Resource
    private DmGySwryService dmGySwryService;
    @Resource
    private DmJcSwjcayztService dmJcSwjcayztService;

    @SuppressWarnings({"rawtypes", "unchecked"})
    @Override
    public IPage<JcAyxxEntity> pageInfo(JcAyxxEntity jcAyxxEntity) {

        String currentUserId = httpSessionService.getCurrentUserId();
        String currentDeptId = httpSessionService.getCurrentDeptId();

        Page page = new Page(jcAyxxEntity.getPage(), jcAyxxEntity.getLimit());
        LambdaQueryWrapper<JcAyxxEntity> queryWrapper = Wrappers.lambdaQuery();

        queryWrapper.eq(JcAyxxEntity::getZfbz_1, "N");
        queryWrapper.eq(JcAyxxEntity::getQdtj, "SSJ");
        queryWrapper.isNull(JcAyxxEntity::getJcajxxuuid);

        IPage<JcAyxxEntity> iPage = this.page(page, queryWrapper);

        return iPage;

    }

    @SuppressWarnings({"rawtypes", "unchecked"})
    @Override
    public IPage<JcAyxxEntity> pageInfo(JcAyxxDebugJgryEntity jcAyxxDebugJgryEntity) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String currentDeptId = httpSessionService.getCurrentDeptId();
        Page page = new Page(jcAyxxDebugJgryEntity.getPage(), jcAyxxDebugJgryEntity.getLimit());
        LambdaQueryWrapper<JcAyxxEntity> queryWrapper = Wrappers.lambdaQuery();
        if (TsBqUtils.isNotNull(jcAyxxDebugJgryEntity.getJcaybh())) {
            queryWrapper.like(JcAyxxEntity::getJcaybh, jcAyxxDebugJgryEntity.getJcaybh());
        }
        if (TsBqUtils.isNotNull(jcAyxxDebugJgryEntity.getNsrsbh())) {
            queryWrapper.like(JcAyxxEntity::getNsrsbh, jcAyxxDebugJgryEntity.getNsrsbh());
        }
        if (TsBqUtils.isNotNull(jcAyxxDebugJgryEntity.getNsrmc())) {
            queryWrapper.like(JcAyxxEntity::getNsrmc, jcAyxxDebugJgryEntity.getNsrmc());
        }
        queryWrapper.eq(JcAyxxEntity::getZfbz_1, "N");
        queryWrapper.eq(JcAyxxEntity::getQdtj, "SSJ");
        queryWrapper.isNotNull(JcAyxxEntity::getAy_bh);
        queryWrapper.like(JcAyxxEntity::getAydjjg_dm, currentDeptId.substring(0, 9));
        if (TsBqUtils.isNotNull(jcAyxxDebugJgryEntity.getLrsjq())) {
            queryWrapper.between(JcAyxxEntity::getLrrq, sdf.parse(jcAyxxDebugJgryEntity.getLrsjq()), sdf.parse(jcAyxxDebugJgryEntity.getLrsjz()));
        } else {
            queryWrapper.ge(JcAyxxEntity::getLrrq, sdf.parse("2023-01-01"));
        }
        IPage<JcAyxxEntity> iPage = this.page(page, queryWrapper);
//        List<JcAyxxEntity> jcAyxxEntityList = iPage.getRecords();
//
//        for (JcAyxxEntity jcAyxxEntity : jcAyxxEntityList) {
//            DmGySwjgEntity dmGySwjgEntity = dmGySwjgService.getSwjgDm(jcAyxxEntity.getAyszjg_dm());
//            jcAyxxEntity.setJsks(dmGySwjgEntity.getSwjgmc());
//            String ajjcztDm = jcAyxxEntity.getAjjcztDm();
//            if (TsBqUtils.isNotNull(ajjcztDm)) {
//                DmJcAjztEntity dmJcAjztEntity = dmJcAjztService.getByAjztDm(ajjcztDm);
//                String ajztmc = dmJcAjztEntity.getAjztmc();
//                jcAyxxEntity.setAjztmc(ajztmc);
//            }
//        }
        return iPage;
    }

    @Override
    @SuppressWarnings({"rawtypes", "unchecked"})
    public IPage<JcAyxxDebugJgryEntity> pageInfoDeno(JcAyxxDebugJgryEntity jcAyxxDebugJgryEntity) {
        String currentUserId = httpSessionService.getCurrentUserId();
        Page page = new Page(jcAyxxDebugJgryEntity.getPage(), jcAyxxDebugJgryEntity.getLimit());
        LambdaQueryWrapper<JcAyxxDebugJgryEntity> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(JcAyxxDebugJgryEntity::getCreateId, currentUserId);
        IPage<JcAyxxDebugJgryEntity> iPage = jcAyxxDebugJgryService.page(page, queryWrapper);
        List<JcAyxxDebugJgryEntity> records = iPage.getRecords();
        if (TsBqUtils.isNotNull(records)) {
            for (JcAyxxDebugJgryEntity jcAyxxDebugJgryEntity1 : records) {
                String swjgDm = jcAyxxDebugJgryEntity1.getSwjgDm();
                DmGySwjgEntity dmGySwjgEntity = dmGySwjgService.getSwjgDm(swjgDm);
                String swjgmc = dmGySwjgEntity.getSwjgmc();
                jcAyxxDebugJgryEntity1.setSwjgDm(swjgmc);
                String jczcryDm = jcAyxxDebugJgryEntity1.getJczcryDm();
                DmGySwryEntity zcSwry = dmGySwryService.getSwry(jczcryDm);
                String swryXm = zcSwry.getSwryxm();
                jcAyxxDebugJgryEntity1.setJczcryDm(jczcryDm + "|" + swryXm);
                String tzrId = jcAyxxDebugJgryEntity1.getCreateId();
                DmGySwryEntity tzrentity = dmGySwryService.getSwry(tzrId);
                String tzrXm = tzrentity.getSwryxm();
                jcAyxxDebugJgryEntity1.setCreateId(tzrId + "|" + tzrXm);
                String jcxcryDm = jcAyxxDebugJgryEntity1.getJcxcryDm();
                String[] xcSwryDmArr = jcxcryDm.split(",");
                List<String> xcSwryDmList = Arrays.asList(xcSwryDmArr);
                StringBuilder xcSwryXm = new StringBuilder();
                for (String swryDm : xcSwryDmList) {
                    DmGySwryEntity xcSwry = dmGySwryService.getSwry(swryDm);
                    xcSwryXm.append(swryDm).append("|").append(xcSwry.getSwryxm()).append(",");
                }
                if (xcSwryXm.length() > 0) {
                    xcSwryXm.deleteCharAt(xcSwryXm.length() - 1);
                }
                jcAyxxDebugJgryEntity1.setJcxcryDm(xcSwryXm.toString());
            }
        }
        return iPage;
    }

    @Override
    @SuppressWarnings({"rawtypes", "unchecked"})
    public IPage<JcAyxxDebugJgryEntity> queryJcayxx(JcAyxxDebugJgryEntity jcAyxxDebugJgryEntity) {
        String currentUserId = httpSessionService.getCurrentUserId();
        Page page = new Page(jcAyxxDebugJgryEntity.getPage(), jcAyxxDebugJgryEntity.getLimit());
        LambdaQueryWrapper<JcAyxxDebugJgryEntity> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(JcAyxxDebugJgryEntity::getCreateId, currentUserId);
        IPage<JcAyxxDebugJgryEntity> iPage = jcAyxxDebugJgryService.page(page, queryWrapper);
        List<JcAyxxDebugJgryEntity> records = iPage.getRecords();
        if (TsBqUtils.isNotNull(records)) {
            for (JcAyxxDebugJgryEntity jcAyxxDebugJgryEntity1 : records) {
                String swjgDm = jcAyxxDebugJgryEntity1.getSwjgDm();
                DmGySwjgEntity dmGySwjgEntity = dmGySwjgService.getSwjgDm(swjgDm);
                String swjgmc = dmGySwjgEntity.getSwjgmc();
                jcAyxxDebugJgryEntity1.setSwjgDm(swjgmc);
                String jczcryDm = jcAyxxDebugJgryEntity1.getJczcryDm();
                DmGySwryEntity zcSwry = dmGySwryService.getSwry(jczcryDm);
                String swryXm = zcSwry.getSwryxm();
                jcAyxxDebugJgryEntity1.setJczcryDm(jczcryDm + "|" + swryXm);
                String tzrId = jcAyxxDebugJgryEntity1.getCreateId();
                DmGySwryEntity tzrentity = dmGySwryService.getSwry(tzrId);
                String tzrXm = tzrentity.getSwryxm();
                jcAyxxDebugJgryEntity1.setCreateId(tzrId + "|" + tzrXm);
                String jcxcryDm = jcAyxxDebugJgryEntity1.getJcxcryDm();
                String[] xcSwryDmArr = jcxcryDm.split(",");
                List<String> xcSwryDmList = Arrays.asList(xcSwryDmArr);
                StringBuilder xcSwryXm = new StringBuilder();
                for (String swryDm : xcSwryDmList) {
                    DmGySwryEntity xcSwry = dmGySwryService.getSwry(swryDm);
                    xcSwryXm.append(swryDm).append("|").append(xcSwry.getSwryxm()).append(",");
                }
                if (xcSwryXm.length() > 0) {
                    xcSwryXm.deleteCharAt(xcSwryXm.length() - 1);
                }
                jcAyxxDebugJgryEntity1.setJcxcryDm(xcSwryXm.toString());
            }
        }
        return iPage;
    }

    @SuppressWarnings({"unchecked", "rawtypes"})
    @Override
    public IPage<JcAyxxEntity> pageInfo(WorkflowInspectionHearEntity workflowInspectionHear) throws ParseException {
        String currentDeptId = httpSessionService.getCurrentDeptId();
        Page page = new Page(workflowInspectionHear.getPage(), workflowInspectionHear.getLimit());
        LambdaQueryWrapper<JcAyxxEntity> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(JcAyxxEntity::getQdtj, "SSJ");
        queryWrapper.isNotNull(JcAyxxEntity::getQdtj);
        // queryWrapper.apply("not exists (select 1 from JC_AYXX_DEBUG where JC_AYXX_DEBUG.jcayxxuuid = Jc_Ayxx.jcajxxuuid)");
        queryWrapper.apply("exists (select 1 from hx_jc.JC_AJXX where JC_AJXX.jcajxxuuid = Jc_Ayxx.jcajxxuuid)");
        queryWrapper.like(JcAyxxEntity::getAydjjg_dm, currentDeptId.substring(0, 9));
        IPage<JcAyxxEntity> iPage = this.page(page, queryWrapper);
        List<JcAyxxEntity> records = iPage.getRecords();
        for (JcAyxxEntity jcAyxxEntity : records) {
            String relevance = jcAyxxEntity.getJcajxxuuid();
            JcAjxxEntity jcAjxxEntity = jcAjxxService.getByJcajxxuuid(relevance);
            BeanUtils.copyProperties(jcAjxxEntity, jcAyxxEntity);
            String ajjcztDm = jcAyxxEntity.getAjjcztDm();
            if (TsBqUtils.isNotNull(ajjcztDm)) {
                DmJcAjztEntity dmJcAjztEntity = dmJcAjztService.getByAjztDm(ajjcztDm);
                String ajztmc = dmJcAjztEntity.getAjztmc();
                jcAyxxEntity.setAjjcztDm(ajztmc);
            }
        }
        return iPage;
    }

    @SuppressWarnings({"unchecked", "rawtypes"})
    @Override
    public IPage<JcAyxxDebugEntity> pageInfoDeno(WorkflowInspectionHearEntity workflowInspectionHear) {
        String currentDeptId = httpSessionService.getCurrentDeptId();
        String currentUserId = httpSessionService.getCurrentUserId();
        Page page = new Page(workflowInspectionHear.getPage(), workflowInspectionHear.getLimit());
        LambdaQueryWrapper<JcAyxxDebugEntity> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(JcAyxxDebugEntity::getCreateId, currentUserId);

        IPage<JcAyxxDebugEntity> iPage = jcAyxxDebugService.page(page, queryWrapper);

        List<JcAyxxDebugEntity> records = iPage.getRecords();
        if (TsBqUtils.isNotNull(records)) {
            for (JcAyxxDebugEntity jcAyxxDebugEntity : records) {

                String relevance = jcAyxxDebugEntity.getJcayxxuuid();
                String content = jcAyxxDebugEntity.getContent();
                String swjgDm = jcAyxxDebugEntity.getSwjgDm();
                DmGySwjgEntity dmGySwjgEntity = dmGySwjgService.getSwjgDm(swjgDm);
                String swjgmc = dmGySwjgEntity.getSwjgmc();


                JcAjxxEntity jcAjxxEntity = jcAjxxService.getByJcajxxuuid(relevance);
                BeanUtils.copyProperties(jcAjxxEntity, jcAyxxDebugEntity);

                String ajjcztDm = jcAyxxDebugEntity.getAjjcztDm();
                if (TsBqUtils.isNotNull(ajjcztDm)) {
                    DmJcAjztEntity dmJcAjztEntity = dmJcAjztService.getByAjztDm(ajjcztDm);
                    String ajztmc = dmJcAjztEntity.getAjztmc();
                    jcAyxxDebugEntity.setAjjcztDm(ajztmc);

                }
                jcAyxxDebugEntity.setContent(content);
                jcAyxxDebugEntity.setSwjg_dm(swjgmc);

            }
        }

        return iPage;
    }

    @Override
    public List<JcAyxxEntity> list(WorkflowInspectionHearEntity workflowInspectionHear) {

        String currentDeptId = httpSessionService.getCurrentDeptId();
        LambdaQueryWrapper<JcAyxxEntity> queryWrapper = Wrappers.lambdaQuery();

        queryWrapper.eq(JcAyxxEntity::getQdtj, "SSJ");
        queryWrapper.isNotNull(JcAyxxEntity::getQdtj);
        // queryWrapper.apply("not exists (select 1 from JC_AYXX_DEBUG where JC_AYXX_DEBUG.jcayxxuuid = Jc_Ayxx.jcajxxuuid)");
        queryWrapper.apply("exists (select 1 from JC_AJXX where JC_AJXX.jcajxxuuid = Jc_Ayxx.jcajxxuuid)");

        queryWrapper.like(JcAyxxEntity::getAydjjg_dm, currentDeptId.substring(0, 9));

        List<JcAyxxEntity> jcAyxxEntityList = this.list(queryWrapper);

        for (JcAyxxEntity jcAyxxEntity : jcAyxxEntityList) {

            String relevance = jcAyxxEntity.getJcajxxuuid();
            JcAjxxEntity jcAjxxEntity = jcAjxxService.getByJcajxxuuid(relevance);
            BeanUtils.copyProperties(jcAjxxEntity, jcAyxxEntity);
            String ajjcztDm = jcAyxxEntity.getAjjcztDm();
            if (TsBqUtils.isNotNull(ajjcztDm)) {
                DmJcAjztEntity dmJcAjztEntity = dmJcAjztService.getByAjztDm(ajjcztDm);
                String ajztmc = dmJcAjztEntity.getAjztmc();
                jcAyxxEntity.setAjjcztDm(ajztmc);

            }
        }

        return jcAyxxEntityList;

    }

    @Override
    public List<JcAyxxEntity> listAyxxJgry(WorkflowInspectionHearEntity workflowInspectionHear) throws ParseException {
        String currentDeptId = httpSessionService.getCurrentDeptId();
        LambdaQueryWrapper<JcAyxxEntity> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(JcAyxxEntity::getZfbz_1, "N");
        queryWrapper.eq(JcAyxxEntity::getQdtj, "SSJ");
        queryWrapper.isNotNull(JcAyxxEntity::getAy_bh);
        queryWrapper.like(JcAyxxEntity::getAydjjg_dm, currentDeptId.substring(0, 9));
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        queryWrapper.ge(JcAyxxEntity::getLrrq, sdf.parse("2023-01-01"));
        return this.list(queryWrapper);
    }

    @Override
    public JcAyxxEntity getByJcayxxuuid(String jcayxxuuid) {
        return this.getById(jcayxxuuid);
    }

    @Override
    public List<JcAyxxEntity> getAyxxJgry(JcAyxxDebugJgryEntity jcAyxxDebugJgryEntity) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String currentDeptId = httpSessionService.getCurrentDeptId();
        LambdaQueryWrapper<JcAyxxEntity> queryWrapper = Wrappers.lambdaQuery();
        if (TsBqUtils.isNotNull(jcAyxxDebugJgryEntity.getJcaybh())) {
            queryWrapper.like(JcAyxxEntity::getJcaybh, jcAyxxDebugJgryEntity.getJcaybh());
        }
        if (TsBqUtils.isNotNull(jcAyxxDebugJgryEntity.getNsrsbh())) {
            queryWrapper.like(JcAyxxEntity::getNsrsbh, jcAyxxDebugJgryEntity.getNsrsbh());
        }
        if (TsBqUtils.isNotNull(jcAyxxDebugJgryEntity.getNsrmc())) {
            queryWrapper.like(JcAyxxEntity::getNsrmc, jcAyxxDebugJgryEntity.getNsrmc());
        }
        queryWrapper.eq(JcAyxxEntity::getZfbz_1, "N");
        queryWrapper.eq(JcAyxxEntity::getQdtj, "SSJ");
        queryWrapper.isNotNull(JcAyxxEntity::getAy_bh);
        queryWrapper.like(JcAyxxEntity::getAydjjg_dm, currentDeptId.substring(0, 9));
        if (TsBqUtils.isNotNull(jcAyxxDebugJgryEntity.getLrsjq())) {
            queryWrapper.between(JcAyxxEntity::getLrrq, sdf.parse(jcAyxxDebugJgryEntity.getLrsjq()), sdf.parse(jcAyxxDebugJgryEntity.getLrsjz()));
        } else {
            queryWrapper.ge(JcAyxxEntity::getLrrq, sdf.parse("2023-01-01"));
        }
        return this.list(queryWrapper);
    }

    @Override
    public List<JcAyxxEntity> queryzcAyxx(JcAyxxEntity jcAyxxEntity) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String currentDeptId = httpSessionService.getCurrentDeptId();
        LambdaQueryWrapper<JcAyxxEntity> queryWrapper = Wrappers.lambdaQuery();
        if (TsBqUtils.isNotNull(jcAyxxEntity.getJcaybh())) {
            queryWrapper.like(JcAyxxEntity::getJcaybh, jcAyxxEntity.getJcaybh());
        }
        if (TsBqUtils.isNotNull(jcAyxxEntity.getNsrsbh())) {
            queryWrapper.like(JcAyxxEntity::getNsrsbh, jcAyxxEntity.getNsrsbh());
        }
        if (TsBqUtils.isNotNull(jcAyxxEntity.getNsrmc())) {
            queryWrapper.like(JcAyxxEntity::getNsrmc, jcAyxxEntity.getNsrmc());
        }
        if (TsBqUtils.isNotNull(jcAyxxEntity.getJsks())) {
            queryWrapper.like(JcAyxxEntity::getAyszjgDm, jcAyxxEntity.getJsks());
        }
        queryWrapper.eq(JcAyxxEntity::getZfbz_1, "N");
        queryWrapper.eq(JcAyxxEntity::getQdtj, "SSJ");
        queryWrapper.isNotNull(JcAyxxEntity::getAy_bh);
        queryWrapper.like(JcAyxxEntity::getAydjjg_dm, currentDeptId.substring(0, 9));
        if (TsBqUtils.isNotNull(jcAyxxEntity.getLasjq())) {
            queryWrapper.between(JcAyxxEntity::getLrrq, sdf.parse(jcAyxxEntity.getLasjq()), sdf.parse(jcAyxxEntity.getLasjz()));
        } else {
            queryWrapper.ge(JcAyxxEntity::getLrrq, sdf.parse("2023-01-01"));
        }
        List<JcAyxxEntity> jcAyxxEntityList = this.list(queryWrapper);
        return jcAyxxEntityList;
    }

    @Override
    public IPage<JcAyxxEntity> queryPagezcAyxx(JcAyxxEntity jcAyxxEntity) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String currentDeptId = httpSessionService.getCurrentDeptId();
        Page page = new Page(jcAyxxEntity.getPage(), jcAyxxEntity.getLimit());
        LambdaQueryWrapper<JcAyxxEntity> queryWrapper = Wrappers.lambdaQuery();
        if (TsBqUtils.isNotNull(jcAyxxEntity.getJcayyjqxDm())) {
            if (jcAyxxEntity.getJcayyjqxDm().equals(Constants.AJZT_LX_WTZ)) {
                queryWrapper.isNull(JcAyxxEntity::getJcayyjqxDm);
            } else {
                queryWrapper.eq(JcAyxxEntity::getJcayyjqxDm, jcAyxxEntity.getJcayyjqxDm());
            }
        }
        if (TsBqUtils.isNotNull(jcAyxxEntity.getJcaybh())) {
            queryWrapper.like(JcAyxxEntity::getJcaybh, jcAyxxEntity.getJcaybh());
        }
        //案件状态代码
        if (TsBqUtils.isNotNull(jcAyxxEntity.getSwjcayztDm())) {
            queryWrapper.like(JcAyxxEntity::getSwjcayztDm, jcAyxxEntity.getSwjcayztDm());
        }
        if (TsBqUtils.isNotNull(jcAyxxEntity.getNsrsbh())) {
            queryWrapper.like(JcAyxxEntity::getNsrsbh, jcAyxxEntity.getNsrsbh());
        }
        if (TsBqUtils.isNotNull(jcAyxxEntity.getNsrmc())) {
            queryWrapper.like(JcAyxxEntity::getNsrmc, jcAyxxEntity.getNsrmc());
        }
        if (TsBqUtils.isNotNull(jcAyxxEntity.getTzhks())) {
            DmGySwjgEntity dmGySwjgEntity = dmGySwjgService.getSwjgDmBySwjgjc(jcAyxxEntity.getTzhks());
            queryWrapper.like(JcAyxxEntity::getAyszbmDm, dmGySwjgEntity.getSwjgDm());
        }
//        queryWrapper.eq(JcAyxxEntity::getZfbz_1, "N");
        queryWrapper.eq(JcAyxxEntity::getQdtj, "SSJ");
        queryWrapper.isNotNull(JcAyxxEntity::getAy_bh);
//        queryWrapper.like(JcAyxxEntity::getAydjjg_dm, currentDeptId.substring(0, 9));
        if (TsBqUtils.isNotNull(jcAyxxEntity.getLasjq())) {
            queryWrapper.between(JcAyxxEntity::getLrrq, sdf.parse(jcAyxxEntity.getLasjq()), sdf.parse(jcAyxxEntity.getLasjz()));
        } else {
            queryWrapper.ge(JcAyxxEntity::getLrrq, sdf.parse("2023-01-01"));
        }
        IPage<JcAyxxEntity> iPage = this.page(page, queryWrapper);
        List<JcAyxxEntity> jcAyxxEntityList = iPage.getRecords();
        for (JcAyxxEntity ayxxEntity : jcAyxxEntityList) {
            if (TsBqUtils.isNull(ayxxEntity.getJcajxxuuid()) || TsBqUtils.isNull(ayxxEntity.getSwjcayztDm())) {
                ayxxEntity.setAjztmc("保存未提交");
            } else {
                DmJcSwjcayztEntity dmJcSwjcayztEntity = dmJcSwjcayztService.getAyztmcByAyztDm(ayxxEntity.getSwjcayztDm());
                ayxxEntity.setAjztmc(dmJcSwjcayztEntity.getSwjcayztmc());
            }
            String swjgDm;
            if (TsBqUtils.isNotNull(ayxxEntity.getAyszbmDm())) {
                swjgDm = ayxxEntity.getAyszbmDm();
            } else {
                swjgDm = ayxxEntity.getAyszjgDm();
            }
            DmGySwjgEntity dmGySwjgEntity = dmGySwjgService.getSwjgDm(swjgDm);
            ayxxEntity.setJsks(dmGySwjgEntity.getSwjgjc());
            ayxxEntity.setTzhks(dmGySwjgEntity.getSwjgjc());
        }
        return iPage;
    }
}
